package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.entity.enums.PayType;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.Pay;

/**
 * QPay is a ORMLite query type for Pay
 * @see Pay
 */
public class QPay extends QEntityBase<Pay> {

    public static final QPay $ = new QPay("PAY");

    public final Column name = field("name").columnName("NAME").varchar(32).notNull().build();

    public final Column payType = field("payType").columnName("PAY_TYPE").enumeString(PayType.class, 1).notNull().build();

    public final Column allowChange = field("allowChange").columnName("ALLOW_CHANGE").notNull().build();

    public final Column allowFavoured = field("allowFavoured").columnName("ALLOW_FAVOURED").notNull().build();

    public final Column defaultValue = field("defaultValue").columnName("DEFAULT_VALUE").decimal(12, 3).build();

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index primaryKey1 = index("PRIMARY_KEY_1").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public QPay(String tableName) {
        super(Pay.class, tableName);
    }

    @Override
    public Pay newInstance() {
        return new Pay();
    }

    @Override
    public Object getFieldValue(Pay instance, String fieldName) {
        switch (fieldName) {
            case "name":
                return instance.getName();
            case "payType":
                return instance.getPayType();
            case "allowChange":
                return instance.getAllowChange();
            case "allowFavoured":
                return instance.getAllowFavoured();
            case "defaultValue":
                return instance.getDefaultValue();
            case "templateId":
                return instance.getTemplateId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(Pay instance, String fieldName, Object value) {
        switch (fieldName) {
            case "name":
                instance.setName((java.lang.String) value);
                break;
            case "payType":
                instance.setPayType((net.apexes.demo.codegen.entity.enums.PayType) value);
                break;
            case "allowChange":
                instance.setAllowChange((java.lang.Boolean) value);
                break;
            case "allowFavoured":
                instance.setAllowFavoured((java.lang.Boolean) value);
                break;
            case "defaultValue":
                instance.setDefaultValue((java.math.BigDecimal) value);
                break;
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

